package com.cakin.javademo;

/**
 * @ClassName: TestDemo
 * @Description: 运算符
 * @Date: 2020/6/13
 * @Author: cakin
 */
public class TestDemo {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int c = 25;
        int d = 25;
        // 求模就是求余
        System.out.println("b % a = " + (b % a)); // 0
        System.out.println("c % a = " + (c % a)); // 5
        // 到底先自增还是先打印，如果++放在前面，就是先加，再打印，如果++是放在后面，就是先打印，后加
        System.out.println("a++   = " + (a++)); // 10
        // a = 11
        System.out.println("a--   = " + (a--)); // 11
        // a =10
        // 查看  d++ 与 ++d 的不同
        System.out.println("d++   = " + (d++)); // 25
        // d = 26
        System.out.println("++d   = " + (++d)); // 27

        int a1 = 3; // 定义一个变量；
        int b1 = ++a1;//自增运算 b1 =4  a1=4
        int c1 = 3;
        int d1 = --c1;//自减运算 c1 = 2 d1 =2
        // ++ 在前，就加再操作，++ 在后，就是先操作，再++
        System.out.println("进行自增运算后的值等于" + b1);
        System.out.println("进行自减运算后的值等于" + d1);

        int a2 = 5;//定义一个变量；
        int b2 = 5;
        int x2 = 2 * ++a2; // x2 = 12 a2=6
        int y2 = 2 * b2++; // y2 = 10 b2=6
        System.out.println("自增运算符前缀运算后a2=" + a2 + ",x2=" + x2);
        System.out.println("自增运算符后缀运算后b2=" + b2 + ",y2=" + y2);

        System.out.println("==============================================");
        int a3 = 10;
        int b3 = 20;
        System.out.println("a == b = " + (a3 == b3) ); // false
        System.out.println("a != b = " + (a3 != b3) ); //true
        System.out.println("a > b = " + (a3 > b3) ); // false
        System.out.println("a < b = " + (a3 < b3) ); // true
        System.out.println("b >= a = " + (b3 >= a3) ); //ture
        System.out.println("b <= a = " + (b3 <= a3) ); //false

        // 0011 1100
        // 011 11000
        // 1111 0000  1111 0000
        // 00001111



    }
}
